home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
ptv2n1.arc
/
DEC2HEX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-03-26
|
623b
|
22 lines
{ This constant definition is required by both Dec2Hex }
{ and Hex2Dec: }
CONST
HexString : array [0..15] of char = '0123456789ABCDEF';
FUNCTION Dec2Hex (Num : word) : string;
{ Returns decimal value as hex string }
VAR
Loop : Byte;
S : string [10];
BEGIN
S := ''; { empty string }
for Loop := 1 to 4 do begin { do 4 chars }
S := HexString [Lo (Num) and $F] + S; { use 4 lowest bits }
Num := Num shr 4; { shift bits right 4 }
end;
Dec2Hex := '$' + S; { return string }
END;